import { type FC } from 'react';
import { Stack } from 'expo-router';
import { StatusBar } from 'expo-status-bar';
import * as SplashScreen from 'expo-splash-screen';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import { RootSiblingParent } from 'react-native-root-siblings';
import RootAuth from '@/layouts/RootAuth';
import { isIos } from '@/utils/helper';

// 在资源加载完成之前，防止启动屏幕自动隐藏.
SplashScreen.preventAutoHideAsync();

const RootLayout: FC = () => {
  return (
    <GestureHandlerRootView>
      <RootSiblingParent>
        <StatusBar style="light" />
        <Stack screenOptions={{ headerShown: false }}>
          <Stack.Screen
            name="signin"
            options={{
              animationDuration: 350,
              animation: isIos() ?
                'slide_from_bottom' :
                'default'
            }}
          />
          <Stack.Screen
            name="(home)"
            options={{
              animation: 'fade',
              animationDuration: 350
            }}
          />
        </Stack>
        <RootAuth />
      </RootSiblingParent>
    </GestureHandlerRootView>
  );
}

export default RootLayout;
